package com.acs.attestation.service.impl;

import com.acs.attestation.entity.CardEntity;
import com.acs.attestation.mapper.CardMapper;
import com.acs.attestation.service.CardService;
import com.acs.attestation.util.FilUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 杰
 * @Description:
 * @date 2022/4/27 23:45
 */
@Service
public class CardServiceImpl implements CardService{
    @Resource
    private CardMapper cardMapper;

    @Override
    public int add(CardEntity cardEntity) {
        FilUtil.fillNewRecord(cardEntity,CardEntity.class);
        int insert = cardMapper.insert(cardEntity);
        return insert;
    }

    @Override
    public int update(CardEntity cardEntity) {
        FilUtil.fillModifyRecord(cardEntity,CardEntity.class);
        int update = cardMapper.updateById(cardEntity);
        return update;
    }

    @Override
    public int del(Long[] ids) {
        CardEntity cardEntity = new CardEntity();
        cardEntity.setDeleted(true);
        int id = cardMapper.update(cardEntity, new QueryWrapper<CardEntity>().in("id", ids));
        return id;
    }


}
